
package cn.books.bookstore.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.util.HashMap;
import java.util.Map;

/**
 * 结果返回体
 */
@JsonSerialize
public enum ResEnum{

    SUCCESS_ENUM(200, "success"),
    ERROR_ENUM(500, "fail");

    public int code;

    public String msg;

    public Object data;

    ResEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public ResEnum setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public ResEnum setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Object getData() {
        return data;
    }

    public ResEnum setData(Object data) {
        this.data = data;
        return this;
    }

    public Map<String, Object> toMap() {
        Map map = new HashMap();
        map.put("msg", msg);
        map.put("code", code);
        map.put("data", data);
        return map;
    }
}
